home *** CD-ROM | disk | FTP | other *** search
- <html>
-
- <head>
-
- <title>DHTML Site Navigator</title>
-
- </head>
-
-
-
- <!-- small style sheet to set the font properties on the menu -->
-
- <style type="text/css">
-
- <!--
-
- all.mnuTxt{
-
- text-decoration:none;
-
- color:black;
-
- font-family:Tahoma,Arial,Helvetica;
-
- font-size:10pt
-
- }
-
- -->
-
- </style>
-
-
-
- <script language="JavaScript1.2">
-
- <!--//
-
-
-
- //initialize the global variables immediately...
-
- var seed = 1;
-
- var lastPage = '';
-
- var timerID = null;
-
- var timerRunning = false;
-
-
-
- //A throwback to my days with JavaScript 1.0 under Netscape 2.0, the ParseArray function builds
-
- //an array on the fly, based on the number of arguments passed to it. Occasionally, this type
-
- //of script is useful for when you're not too clear on how many elements are going to be in the
-
- //array. Added bonus code! It works on any JavaScript compliant browser!
-
- function ParseArray() {
-
- this.length = ParseArray.arguments.length;
-
- for (var i = 0; i < this.length; i++) {
-
- this[i+1] = ParseArray.arguments[i]
-
- }
-
- }
-
-
-
-
-
- //A slideTo variant that uses the global variable 'seed' to increase the movement of the target layer.
-
- function slideTo(targetLayer, targetTop) {
-
- seed = seed * 1.2;
-
- if((targetTop >= 0) && ((targetLayer.top + seed * 1.2) < targetTop)) {
-
- if (targetLayer.top < targetTop) targetLayer.top = targetLayer.top + seed;
-
- setTimeout('slideTo(document.layers["'+targetLayer.name+'"],'+targetTop+')',1);
-
- } else if((targetTop < 0) && ((targetLayer.top - seed * 1.2) > targetTop)) {
-
- if (targetLayer.top > targetTop) targetLayer.top = targetLayer.top - seed;
-
- setTimeout('slideTo(document.layers["'+targetLayer.name+'"],'+targetTop+')',1);
-
- } else {
-
- //make sure the layer is exactly at its target position and reset the 'seed' variable.
-
- seed = 1;
-
- targetLayer.top = targetTop;
-
- }
-
- }
-
-
-
-
-
- //The fun really starts here... two array are created to hold the titles and urls for the menu
-
- //bar, and initialize the clock. The init() function is called by the onLoad event of the document.
-
- function init() {
-
- //The sTitles array holds the titles of the pages on the select menu.
-
- var sTitles = new ParseArray('Current News',
-
- 'Site Help',
-
- 'Company Info',
-
- 'Feedback');
-
-
-
- //The sUrls array holds the filenames for the pages in the select list.
-
- var sUrls = new ParseArray('content1.htm',
-
- 'content2.htm',
-
- 'content3.htm',
-
- 'content4.htm');
-
-
-
- //This for loop cycles through the sUrls and sTitles arrays, and populates the DHTML
-
- //menu's select box with the page names and URLs to use. To add a new page to the menu,
-
- //you'd simply add or change elements in the two arrays above.
-
- for (var s = 1; s <= sUrls.length; s++) {
-
- var nPage = new Option(sTitles[s], sUrls[s]);
-
- document.layers['sysmenu'].layers['lock'].document.forms[0].pages.options[s] = nPage;
-
- }
-
- //One of the buttons on the menu bar is a clock, so when the page is loaded,
-
- //the clock is set and fired up to keep track of the current time for the user.
-
- stopclock()
-
- showtime()
-
- }
-
-
-
- //Which way to go? The showMenu() function determines the menu bar's current top position and
-
- //fires off the slideTo function to handle the animation. Most importantly, notice the first
-
- //if... block that checks to see if the Auto Hide checkbox is clear before activating any movement.
-
- function showMenu(layerName) {
-
- if (document.layers['sysmenu'].layers['lock'].document.forms[0].hold.checked != false) {
-
- if (document.layers[layerName].top <= -32) {
-
- slideTo(document.layers[layerName], 0);
-
- } else if(document.layers[layerName].left >= 0) {
-
- slideTo(document.layers[layerName], -32);
-
- }
-
- }
-
- }
-
-
-
- //This function stops the clock if necessary. Guards against dreaded memory leaks!
-
- function stopclock(){
-
- if(timerRunning)
-
- clearTimeout(timerID)
-
- timerRunning = false
-
- }
-
-
-
- //A quick hack of the classic showtime() function, this function formats a string with the
-
- //current time, and tacks an 'am' or 'pm' onto it. The big switch from some of the older clock
-
- //functions out there is that it changes the text on a button as opposed to the text in a
-
- //simple text box.
-
- function showtime(){
-
- var now = new Date();
-
- var hours = now.getHours();
-
- var minutes = now.getMinutes();
-
- var timeValue = "" + ((hours > 12) ? hours - 12 : hours);
-
- timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
-
- timeValue += (hours >= 12) ? " pm" : " am";
-
- //notice how the button is referred to via the complete layer hierarchy
-
- document.layers['sysmenu'].layers['lock'].document.forms[0].clock.value = timeValue;
-
- timerID = setTimeout("showtime()",1000);
-
- timerRunning = true;
-
- }
-
-
-
- //the openPage function grabs the value of the current selection from the 'pages' select
-
- //object and loads it into the 'contentLayer' layer. By loading the external document
-
- //into an existing layerA quick hack of the classic showtime() function, this function formats a string with the
-
- //current time, and tacks an 'am' or 'pm' onto it. The big switch from some of the older clock
-
- function openPage(obj) {
-
- if (obj.pages.selectedIndex > 0) {
-
- lastPage = document.layers['contentLayer'].src;
-
- document.layers['contentLayer'].src=obj.pages.options[obj.pages.selectedIndex].value;
-
- }
-
- }
-
-
-
- //-->
-
- </script>
-
-
-
- <body onLoad="init()" bgcolor="black">
-
-
-
- <!-- the first layer uses mouseover and mouseout events to determine whether the layer -->
-
- <!-- is shown or hidden. It also serves as the parent layer for the rest of the menu. -->
-
- <layer id="sysmenu"
-
- onMouseOver="showMenu('sysmenu')"
-
- onMouseOut="showMenu('sysmenu')" bgcolor="silver" width=99% height=34 left=0 top=0>
-
-
-
-
-
- <!-- Graphics? Not here! The shadow is a 1 pixel tall layer in a darker shade of gray. -->
-
- <layer bgcolor="gray" width=100% height=1 left=0 top=33></layer>
-
-
-
- <!-- The menu is held within the 'lock' layer's document. I used a table here to simplify -->
-
- <!ùthe task of keeping the form elements lined up. -->
-
- <layer id="lock" width=100% height=27 left=5 top=3>
-
- <table cellspacing=0 cellpadding=0 border=0 width=100%>
-
- <tr>
-
- <form name="locker"><td align=center valign=middle>
-
- <span class="mnuTxt"><input type="checkbox" name="hold">Auto Hide |
-
- <input type="button" value="Home" onClick="parent.window.document.layers['contentLayer'].src='content0.htm'" > |
-
- <select size=1 name="pages">
-
- <option value=""> ---- Site Quick Navigator ----
-
- <option value="">
-
- <option value="">
-
- <option value="">
-
- <option value="">
-
- </select> <input type="button" value="Open"
-
- onClick="openPage(this.form)"> |
-
- <input type="button" name="clock" value=" 00:00 "> |
-
- <input type="button" value="Exit" onClick="self.close()" >
-
-
-
- </span>
-
- </td></form>
-
- </tr>
-
- </table>
-
- </layer>
-
-
-
- </layer>
-
-
-
- <!ùthis layer serves as the screen, or canvas that the other pages are loaded in. -->
-
- <layer top=45 left=200 id="contentLayer" height=245 width=400 src="content0.htm">
-
-
-
- </layer>
-
-
-
- </body>
-
- </html>
-
-
-
-